﻿using System.CodeDom;
using Roslyn.Compilers.CSharp;

namespace WeaverCustomTool
{
    public static class INotifyPropertyChangedExtensions
    {
        /// <summary>
        /// Implements the INotify property changed pattern in setter.
        /// </summary>
        /// <param name="property">The property.</param>
        public static INotifyPropertyChangedDeclaration ImplementINotifyPropertyChanged(this CodeMemberProperty property)
        {
            return new INotifyPropertyChangedDeclaration(property);
        }

        /// <summary>
        /// Checks if INotifyPropertyChanged is used.
        /// </summary>
        /// <param name="interface">The interface.</param>
        /// <returns></returns>
        public static bool NeedsINotifyPropertyChangedImplementation(this InterfaceDeclarationSyntax @interface)
        {
            return new INotifyPropertyChangedDeclaration().
                    CheckIfInotifyPropertyChangedImplementationIsRequiredFromInterface(@interface);
        }
    }
}
